<!doctype HTML public "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<title>Bloomberg Development Environment</title>
<html>
<pre>
// Copyright 2019-2023 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// bmqt_compressionalgorithmtype.h                                    -*-C++-*-
#ifndef INCLUDED_BMQT_COMPRESSIONALGORITHMTYPE
#define INCLUDED_BMQT_COMPRESSIONALGORITHMTYPE

//@PURPOSE: Provide an enumeration for different compression algorithm types.
//
//@CLASSES:
//  bmqt::CompressionAlgorithmType: Type of compression algorithm
//
//@DESCRIPTION: Provide an enumeration, &#39;bmqt::CompressionAlgorithmType&#39; for
// different types of compression algorithm.
//
//: o !NONE!: No compression algorithm was specified
//: o !ZLIB!: The compression algorithm is ZLIB

// BMQ
#include &lt;bmqscm_version.h&gt;

// BDE
#include &lt;bsl_ostream.h&gt;
#include &lt;bsl_string.h&gt;

namespace BloombergLP {
namespace bmqt {

                    // ===============================
                    // struct CompressionAlgorithmType
                    // ===============================

struct CompressionAlgorithmType {
    // This struct defines various types of compression algorithms.

    // TYPES
    enum Enum {
        e_UNKNOWN = -1
      , e_NONE    = 0
      , e_ZLIB    = 1
    };

    // CONSTANTS
    static const int k_LOWEST_SUPPORTED_TYPE  = e_NONE;
        // NOTE: This value must always be equal to the lowest type in the
        // enum because it is being used as a lower bound to verify that a
        // header&#39;s &#39;CompressionAlgorithmType&#39; field is a supported type.

    static const int k_HIGHEST_SUPPORTED_TYPE = e_ZLIB;
        // NOTE: This value must always be equal to the highest type in the
        // enum because it is being used as an upper bound to verify that a
        // header&#39;s &#39;CompressionAlgorithmType&#39; field is a supported type.

    // CLASS METHODS
    static
    bsl::ostream&amp; print(bsl::ostream&amp;                  stream,
                        CompressionAlgorithmType::Enum value,
                        int                            level = 0,
                        int                            spacesPerLevel = 4);
        // Write the string representation of the specified enumeration &#39;value&#39;
        // to the specified output &#39;stream&#39;, and return a reference to
        // &#39;stream&#39;.  Optionally specify an initial indentation &#39;level&#39;, whose
        // absolute value is incremented recursively for nested objects.  If
        // &#39;level&#39; is specified, optionally specify &#39;spacesPerLevel&#39;, whose
        // absolute value indicates the number of spaces per indentation level
        // for this and all of its nested objects.  If &#39;level&#39; is negative,
        // suppress indentation of the first line.  If &#39;spacesPerLevel&#39; is
        // negative, format the entire output on one line, suppressing all but
        // the initial indentation (as governed by &#39;level&#39;).  See &#39;toAscii&#39; for
        // what constitutes the string representation of a
        // &#39;CompressionAlgorithmType::Enum&#39; value.

    static const char *toAscii(CompressionAlgorithmType::Enum value);
        // Return the non-modifiable string representation corresponding to the
        // specified enumeration &#39;value&#39;, if it exists, and a unique (error)
        // string otherwise.  The string representation of &#39;value&#39; matches its
        // corresponding enumerator name with the &quot;e_&quot; prefix eluded.  For
        // example:
        //..
        //  bsl::cout &lt;&lt; CompressionAlgorithmType::toAscii(
        //                              CompressionAlgorithmType::e_NONE);
        //..
        // will print the following on standard output:
        //..
        //  NONE
        //..
        // Note that specifying a &#39;value&#39; that does not match any of the
        // enumerators will result in a string representation that is distinct
        // from any of those corresponding to the enumerators, but is otherwise
        // unspecified.

    static bool fromAscii(CompressionAlgorithmType::Enum *out,
                          const bsl::string&amp;              str);
        // Update the specified &#39;out&#39; with correct enum corresponding to the
        // specified string &#39;str&#39;, if it exists, and return true.  Otherwise in
        // case of an error or unidentified string, return false.  The expected
        // &#39;str&#39; is the enumerator name with the &quot;e_&quot; prefix excluded.
        // For example:
        //..
        //  CompressionAlgorithmType::fromAscii(out, NONE);
        //..
        //  will return true and the value of &#39;out&#39; will be:
        //..
        //  bmqt::CompresssionAlgorithmType::e_NONE
        //..
        // Note that specifying a &#39;str&#39; that does not match any of the
        // enumerators excluding &quot;e_&quot; prefix will result in the function
        // returning false and the specified &#39;out&#39; will not be touched.

    static bool isValid(const bsl::string *str, bsl::ostream&amp; stream);
        // Return true incase of valid specified &#39;str&#39; i.e. a enumerator name
        // with the &quot;e_&quot; prefix excluded.  Otherwise in case of invalid &#39;str&#39;
        // return false and populate the specified &#39;stream&#39; with error message.
};

// FREE OPERATORS
bsl::ostream&amp; operator&lt;&lt;(bsl::ostream&amp;                  stream,
                         CompressionAlgorithmType::Enum value);
    // Format the specified &#39;value&#39; to the specified output &#39;stream&#39; and return
    // a reference to the modifiable &#39;stream&#39;.

}  // close package namespace

// ============================================================================
//                             INLINE DEFINITIONS
// ============================================================================

                    // ===============================
                    // struct CompressionAlgorithmType
                    // ===============================

// FREE OPERATORS
inline
bsl::ostream&amp;
bmqt::operator&lt;&lt;(bsl::ostream&amp;                        stream,
                 bmqt::CompressionAlgorithmType::Enum value)
{
    return bmqt::CompressionAlgorithmType::print(stream, value, 0, -1);
}

}  // close enterprise namespace

#endif
</pre>
</body>
</html>
